#include <string.h>

int strlen(char *buffer)
{
	int i = 0;
	while(buffer[i] != '\0') ++i;
	return i;
}

void strcpy(char *destination, const char *source)
{
	int i;
	int size = strlen((char*)source);
	for(i = 0; i < size; i++)
		destination[i] = source[i];
}

int strcmp(char *s1, char *s2)
{
	for(; *s1 == *s2; ++s1, ++s2)
	{
		if(*s1 == 0) return 0;
	}
  return *(unsigned char *) s1 < *(unsigned char *) s2 ? -1 : 1;

}

void itoa(int num, char *buffer)
{
	if(num == 0)
	{
		buffer[0] = '0';
		buffer[1] = '\0';
	}
	else
	{
		int i = 0;
		int n = 0;
		char aux[12];
		while(num > 0)
		{
			aux[i] = '0' + num%10;
			num = num/10;
			++i;
			++n;
		}
		aux[n] = '\0';
		i = 0;
		while(aux[i] != '\0')
		{
			buffer[i] = aux[n-i-1];
			++i;
		}
		buffer[n] = '\0';
	}
}
